#include "image.h"

uint Image::getHeight() const{
	return _oImage.height();
}
uint Image::getWidth() const{
	return _oImage.width();
}
Image::Image() {}
Image::Image(QImage img) :
	_oImage(img){}
Image::~Image(){}
Pixel Image::getPixel(int x, int y) const{
	return _oImage.pixel(x,y);
}
float Image::getDistance(int x1, int y1,int x2, int y2) const{
	if (	x1<0 || x1>=int(getWidth()) || 
				x2<0 || x2>=int(getWidth()) || 
				y1<0 || y1>=int(getHeight()) ||
				y2<0 || y2>=int(getHeight()))
		return 0;
	MAXVERBOSE("calculating");
	return Image::getPixelDistance(_oImage.pixel(x1,y1),_oImage.pixel(x2,y2));
}
float Image::getPixelDistance(Pixel p1, Pixel p2) {
	return	(	float(abs(qRed(p1)-qRed(p2)))+
						float(abs(qBlue(p1)-qBlue(p2)))+
						float(abs(qGreen(p1)-qGreen(p2))))/3;


}
